/*
 * keyboardin.c
 *
 *  Created on: 15.06.2009
 *      Author: michi
 */
#include <math.h>
void keyboard(unsigned char key, int x, int y) {
	switch (key) {
	case 'w':
		//theta_1 = (theta_1 - degToRad(3));
                theta_1 = (theta_1 - speed * 4);
		ermittelTheta();
		glutPostRedisplay();
		break;
	case 'q':
		//Modulo nur damit man keine winkel > 360 bekommen kann
		theta_1 = (theta_1 +  speed * 4);
		ermittelTheta();
		glutPostRedisplay();
		break;



	case 'x':
		xx = (xx + 5) % 360;
		glutPostRedisplay();
		break;
	case 'y':
		yy = (yy + 5) % 360;
		glutPostRedisplay();
		break;
	case 'c':
		zz = (zz + 5) % 360;
		glutPostRedisplay();
		break;

	case 's':
		xx = (xx - 5) % 360;
		glutPostRedisplay();
		break;
	case 'a':
		yy = (yy - 5) % 360;
		glutPostRedisplay();
		break;
	case 'd':
		zz = (zz - 5) % 360;
		glutPostRedisplay();
		break;
	case 'z':
		zoomFaktor += 5.0;
		glutPostRedisplay();
		break;
		/* n:  Schiebe Kamera um 0,5 nach vorne */
	case 'h':
		zoomFaktor -= 5.0;
		glutPostRedisplay();
		break;
        case '+':
                if(richtung &&  fabsl(speed) <=maxSpeed){
		speed  = speed + (fabsl(speed) * speedIncrease);
                if(fabsl(speed) < minSpeed) speed = minSpeed;
                }
                if(!richtung &&  fabsl(speed) <=maxSpeed){
		speed  = speed - (fabsl(speed) *speedIncrease);
                if(fabsl(speed) <= minSpeed) speed = 0.0;
                }
                if(fabsl(speed)>=maxSpeed){
                if(richtung)
                  speed = maxSpeed ;
                else speed = -maxSpeed;
                }
            //    printf("richtung: %i , speed: %f\n",richtung,speed);
		break;
        case '-':
                if(!richtung && fabsl(speed) <=maxSpeed){
		speed = speed + (fabsl(speed) * speedIncrease);
                if(fabsl(speed) < minSpeed) speed = 0.0;
                }
                if(richtung  && fabsl(speed) <=maxSpeed){
                speed  = speed - (fabsl(speed) *speedIncrease);
                if(fabsl(speed) <=minSpeed) speed = minSpeed;  
                }
                if(fabsl(speed)>=maxSpeed){
                if(!richtung)
                  speed = -maxSpeed ;
                else speed = maxSpeed;
                }
             //   printf("richtung: %i , speed: %f\n",richtung,speed);
		break;
        case 'm':
		if(animate ==1) animate = 0;
                else animate = 1;
		break;
        case 'n':
		
                richtung = richtung * -1;
		break;
	case 27:
		exit(0);
		break;
	default:
		break;
	}
}


